#pragma once
#include "Hash.h"

using namespace hash_table;

namespace zzzyh 
{
	template<class K,class V>
	class unordered_map
	{
		struct KFromT
		{
			const K& operator()(const pair<const K, V>& t)
			{
				return t.first;
			}
		};
	public:
		typedef typename Hash<K, pair<const K, V>, KFromT>::Iterator  iterator;
		typedef typename Hash<K, pair<const K, V>, KFromT>::ConstIterator  c_iterator;


		iterator begin() {
			return _hash.begin();
		}
		iterator end() {
			return _hash.end();
		}

		c_iterator begin() const
		{
			return _hash.begin();
		}
		c_iterator end() const
		{
			return _hash.end();
		}
		pair<iterator, bool> insert(const pair< K, V>& t)
		{
			return _hash.insert(t);
		}

		iterator find(const K& key)
		{
			return _hash.find(key);
		}

		bool erase(const K& key)
		{
			return _hash.erase();
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> it = insert({ key,V() });
			return it.first->second;
		}
	private:
		Hash<K, pair<const  K, V>, KFromT> _hash;
	};
}